package com.wangxiaotao.Dao;

import com.wangxiaotao.Pojo.Goods;
import com.wangxiaotao.Pojo.Goods_Shops;
import com.wangxiaotao.Pojo.Shops;
import com.wangxiaotao.Pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShopDao {
    @Select("SELECT * FROM goods WHERE goods_id=#{goods_id}")
    Goods getgoods(int goods_id);

    @Insert("INSERT into shops (username,shop_name,shop_price,shop_total) VALUES(#{username},#{shop_name},#{shop_price},#{shop_total})")
    void addnewshop(Shops shops1);

    @Select("SELECT * FROM shops WHERE username=#{username} AND shopisok=0")
    List<Shops> getshop(String username);

    @Update("UPDATE shops SET shop_num=#{shop_num},shop_total=#{shop_total} WHERE shop_name=#{shop_name}")
    void addshopnum(Shops shops1);

    @Select("SELECT * FROM goods WHERE goods_type=#{goods_type}")
    List<Goods> getgoods_type(int goods_type);

    @Select("SELECT A.*,B.goods_url FROM shops  A  JOIN  goods  B on A.shop_name=B.goods_name WHERE A.username=#{username} AND A.shopisok=0")
    List<Goods_Shops> setshop_car(String username);

    @Update("UPDATE shops SET shop_num=#{shop_num},shop_total=#{shop_total} WHERE shop_id=#{shop_id} AND username=#{username}")
    void shop_num_change(Shops shops);

    @Delete("DELETE FROM shops WHERE shop_id=#{shop_id} AND username=#{username}")
    void deleteshop(Shops shops);

    @Update("UPDATE shops SET shopisok=1 WHERE username=#{username}")
    void postshops(User user);

    @Select("SELECT SUM(shop_num) FROM shops WHERE username=#{username} AND shopisok=0")
    int getallorders(String username);

    @Select("SELECT SUM(shop_total) FROM shops WHERE username=#{username} AND shopisok=0")
    Double getallprice(String username);
}
